package com.gmrz.uas.plugin.faceprint;

import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.util.Arrays;

import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.*;

/**
 * Created by gongyuqiang on 2017/5/8.
 */
public class CryptoUtil {

    static final String D5 = "d5";
    static final String M = "m";

    public static String getMD5Digest(String data) {
        try {
            byte[] bytes = null;
            MessageDigest md = MessageDigest.getInstance(M+D5);
            md.update(data.getBytes("UTF-8"));
            bytes = md.digest();

            StringBuilder stringBuilder = new StringBuilder("");
            for (int i = 0; i < bytes.length; i++) {
                int v = bytes[i] & 0xFF;
                String hv = Integer.toHexString(v);
                if (hv.length() < 2) {
                    stringBuilder.append(0);
                }
                stringBuilder.append(hv);
            }
            return stringBuilder.toString();
        } catch (GeneralSecurityException e) {
            throw new IllegalArgumentException(e);
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException(e);
        }
    }

    public static byte[] getSecret(String data) {
        try {
            byte[] decokey = new byte[24];
            byte[] padd = {0, 0, 0, 0, 0, 0, 0, 0};
            byte[] bytes = null;
            MessageDigest md = MessageDigest.getInstance(M+D5);
            md.update(data.getBytes("UTF-8"));
            bytes = md.digest();

            System.arraycopy(bytes, 0, decokey, 0, bytes.length);
            System.arraycopy(padd, 0, decokey, bytes.length, padd.length);

            return decokey;
        } catch (GeneralSecurityException e) {
            throw new IllegalArgumentException(e);
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException(e);
        }
    }

    public static byte[] decrypt3DES(byte[] datasource, String password) {
        byte[] bytePassword = password.getBytes();
        //生成密钥
        byte[] tripleDESKey = new byte[24];
        int k = 0;
        int i = 0;
        //初始化Key
        for (i = 0; i < 24; i++) {
            if (k >= bytePassword.length) {
                tripleDESKey[i] = 0;
                ;
            } else {
                tripleDESKey[i] = bytePassword[k];
            }
            k++;
        }
        return decrypt3DESByte(datasource, tripleDESKey);
    }

    public static byte[] decrypt3DESByte(byte[] data, byte[] key) {
        try {
            Key deskey = null;
            DESedeKeySpec spec = new DESedeKeySpec(key);
            SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");
            deskey = keyfactory.generateSecret(spec);
            Cipher cipher = Cipher.getInstance("desede" + "/ECB/PKCS5Padding");
            cipher.init(Cipher.DECRYPT_MODE, deskey);
            byte[] bOut = cipher.doFinal(data);
            return bOut;

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static byte[] encrypt3DES(byte[] datasource, String password) {
        byte[] bytePassword = password.getBytes();
        //生成密钥
        byte[] tripleDESKey = new byte[24];
        int k = 0;
        int i = 0;
        //初始化Key
        for (i = 0; i < 24; i++) {
            if (k >= bytePassword.length) {
                tripleDESKey[i] = 0;
                ;
            } else {
                tripleDESKey[i] = bytePassword[k];
            }
            k++;
        }
        return encrypt3DES(datasource, tripleDESKey);
    }

    public static byte[] encrypt3DES(byte[] data, byte[] key) {
        try {
            Key deskey = null;
            DESedeKeySpec spec = new DESedeKeySpec(key);
            SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("desede");
            deskey = keyfactory.generateSecret(spec);

            Cipher cipher = Cipher.getInstance("desede" + "/ECB/PKCS5Padding");

            cipher.init(Cipher.ENCRYPT_MODE, deskey);
            byte[] bOut = cipher.doFinal(data);

            return bOut;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static boolean initialized = false;
    public static final String ALGORITHM = "AES/ECB/PKCS7Padding";

    /**
     * @param str 要被加密的字符串
     * @param key 加/解密要用的长度为32的字节数组（256位）密钥
     * @return byte[]  加密后的字节数组
     */
    public static byte[] Aes256Encode(String str, byte[] key) {
        initialize();
        byte[] result = null;
        try {
            Cipher cipher = Cipher.getInstance(ALGORITHM, "BC");
            SecretKeySpec keySpec = new SecretKeySpec(key, "AES"); //生成加密解密需要的Key
            cipher.init(Cipher.ENCRYPT_MODE, keySpec);
            result = cipher.doFinal(str.getBytes("UTF-8"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    /**
     * @param bytes 要被解密的字节数组
     * @param key   加/解密要用的长度为32的字节数组（256位）密钥
     * @return String  解密后的字符串
     */
    public static byte[] Aes256Decode(byte[] bytes, byte[] key) {
        initialize();
        try {
            Cipher cipher = Cipher.getInstance(ALGORITHM, "BC");
            SecretKeySpec keySpec = new SecretKeySpec(key, "AES"); //生成加密解密需要的Key
            cipher.init(Cipher.DECRYPT_MODE, keySpec);
            byte[] decoded = cipher.doFinal(bytes);
            return decoded;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void initialize() {
        if (initialized) return;
        Security.addProvider(new BouncyCastleProvider());
        initialized = true;
    }

    /**
     * 　　* 利用java原生的摘要实现SHA256加密
     * 　　* @param str 加密后的报文
     * 　　* @return
     *
     */
    public static byte[] getSHA256(byte[] bytes) {
        MessageDigest messageDigest;
        try {
            messageDigest = MessageDigest.getInstance("SHA-256");
            messageDigest.update(bytes);
            return messageDigest.digest();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
//    public static byte[] bcAes256Encode(String str, byte[] keyData) throws Exception{
//        initialize();
//        final byte[] ivData = new byte[16];
//        final byte[] data = str.getBytes("UTF-8");
//
//        // JCE creation
//        final Cipher c = Cipher.getInstance("AES/ECB/PKCS7Padding");
//
//        // initialization
//        c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(keyData, "AES"), new IvParameterSpec(ivData));
//
//        // and encryption
//        byte[] ciphertext = c.doFinal(data);
//        return ciphertext;
//    }
    public static byte[] bcAes256Decode(byte[] bytes, byte[] key) throws Exception {
        final byte[] ciphertext = bytes;
        PaddedBufferedBlockCipher decryptCipher = null;
        decryptCipher =  new PaddedBufferedBlockCipher(new AESEngine());
        decryptCipher.init(false, new KeyParameter(key));
        int plaintextSize = decryptCipher.processBytes(ciphertext, 0, ciphertext.length, ciphertext, 0);
        plaintextSize += decryptCipher.doFinal(ciphertext, plaintextSize);
        final byte[] plaintext = Arrays.copyOf(ciphertext, plaintextSize);
        return plaintext;
    }
    public static void main(String[] args) throws Exception {
        //test();
        String s1 = "test data";
//        String key = "key";
//        String s2 = "oSDg+m/SHoT3QjWUH16CAw==";
        String key = "r8F82Hpm7zovlcIjCVnwD-Fv8CPSutN-j0_OInXTFn55VndXQTRxcUVLb2lfUnI5Y0xxZ1Qtc3JwbkFFczlh";
        String s2 = "LwW5svsSGmdrNbgnNyCNrx9rPs4Fj5BYS1wepZ3Dk8KtHBHHtLtQ+Q0Ds3viDUZGQwDHnwAJxFfjVn5W0nbfSJmPHSrVk3UIxtEM1aPregQ4MBF2zBR0FvdTP5C1kfOtAREVDPxc6S/uC4dPdwRpCkv52V3V36OF+H42vnrnpvRL+dld1d+jhfh+Nr5656b0csoVqpVmTuMdHU+7vN8HR50fWxNJuxBnoSvye2KVjDgSr9pux8zNnaDTkDqwHdVZW4Qa9Bde49/wzY3diPNPqCLpH/bUNN8wYUWQVBIp6KP63uyBcd2e1udJClUNDinxtwPX3AerWFRJa4ruBNQ+hR7Ik6wcI97Qfvn7dwwt2uVLATTw0+FjRkUZWrPCKilrMS9bDr1IUVcvh1ezWgf2tam57XlHmlT1dXFq/XW1FtVthypeGzRaPhLDyJJUbDDnI9gyRoRYp+yS3G2YSYLpKePDN8Dnc70v7FD5AMiHXXuL6KJrrZrzlgEmrtn0lpY6j4AOUZzgqmcDQ19u2OK7ZYdY+UabEOGXAnfYPpPCIUzeUucmdPIMvLcyx/lb+LpCigdRWX3DOz87L2l4FRMLAw3+qNFKtQom3E7ZRemWx1e0J42gVYS6dpOspzAy2S3qSrGoGyiVBhRZ4JC9J60JaoBKiXY+8wayqx0yR/IKdGblZO3BszsyreIrwzQLdx8YFQW4z3gzapDM2YPGuiGpdz093kKBWjBk4/jLS0fG18dHOniACvs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RTTKmWvAPSKcx0A1OWSSXTM5kf9PBnV7Gg8cWKnop6rxT2eQbLHkmnEEkbPRRXnpkukvHpRVqxYqp00gc8NRlXovzU8Dj/El0Tvtmzf+6je793a5QyGGzZshJk1I7BHBbGdounNEVt/5GQMOEgvRAcm61MDflE9vRcLYbfQE3nWJcODCIy/TMlIaDURBcQgp4Nd8EWFXGzc022uZwaOcvjbr6ih323dAU8KdHS5FFeiiIYDjvhqhiH7KGLoNC/7bnCHbKNku41bfrFrO43Dw1BBgldHhMDlfk4BlSvXE9cFNchKCOf8pOq9KgXkKY5+KALpeAYxX5rlbm9pWN+dtrHEc56w==";

        byte[] keyBytes = getSHA256(key.getBytes());
        //byte[] datas1 = Aes256Encode(s1,keyBytes);

        byte[] datas1 = new sun.misc.BASE64Decoder().decodeBuffer(s2);
        byte[] datas = bcAes256Decode(datas1,keyBytes);//Aes256Decode(datas1,keyBytes);


//        String s1 = "Hqsv8s2d0LoCTiNjL9QRjV-V10QBX8P9jmftZgncmabzhXOGWH6I41JwgN5bp-yO";
//        byte[] datas1 = (s1+s1).getBytes();//new sun.misc.BASE64Decoder().decodeBuffer(s1);
    }
}
